package com.example.xx;

import java.io.IOException;
import java.net.URL;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;


public class MainActivity extends Activity {

	private ImageView imageView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		// get preview
		imageView = (ImageView) findViewById(R.id.imageView1);
		new DoTask().execute();
		
		
		imageView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				//parse ?
				startActivity(new Intent(MainActivity.this, FullImg.class));
			}
		});
	}

	private class DoTask extends AsyncTask<Object, Void, Void> {
		Bitmap bmp;
		
		@Override
		protected void onPreExecute() {
			
		}
		
		@Override
		protected Void doInBackground(Object... args) {
			try {
				URL url = new URL("http://xximg.googlecode.com/files/1352722556398_res.jpg");
				bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
			} catch (IOException e) {

			}
			return null;

		}

		@Override
		protected void onPostExecute(Void result) {
			imageView.setImageBitmap(bmp);
		}
	}
}
